package com.on.smile.impl;

import com.on.smile.dao.CustomerDao;
import com.on.smile.entity.CustomerEntity;
import com.on.smile.service.CustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CustomerImpl implements CustomerService {
    @Resource
    private CustomerDao customerDao;

    @Override
    public void insertCustomer(CustomerEntity customer) {
        customerDao.insertCustomer(customer);
    }

    @Override
    public int deleteCustomer(Long id) {
        return customerDao.deleteCustomer(id);
    }

    @Override
    public int deleteCustomers(List<Long> id) {
        int num = 0;
        for (Long l : id) {
            customerDao.deleteCustomer(l);
            num++;
        }
        return num;
    }

    @Override
    public void updateCustomer(CustomerEntity customer) {
        customerDao.updateCustomer(customer);
    }

    @Override
    public List<CustomerEntity> selectCustomerPage(Long page, Long size) {
        return customerDao.selectCustomerPage((page - 1) * size, size);
    }

    @Override
    public List<CustomerEntity> selectCustomerAll() {
        return customerDao.selectCustomerAll();
    }


}
